package com.feicheng.iou.controller.liftCycle;

import com.feicheng.iou.commom.ReturnCode;
import com.feicheng.iou.exception.SystemException;
import com.feicheng.iou.result.ResultInfo;
import com.feicheng.iou.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author  wuweinan
 * @since 2021-07-01
 * @description 生命周期接口前端控制器
 */
@RestController
@RequestMapping("/iou/lifeCycle")
@Slf4j
public class LifeCycleController {

    @Autowired
    private ResourceService resourceService; //线索实现类

    @Autowired
    private InterviewService interviewService; //接待实现类

    @Autowired
    private TryService tryService; //试听实现类

    @Autowired
    private BackviewService backviewService; //回访实现类

    @Autowired
    private BaomingService baomingService;

    /**
     * @Author wuweinan
     * @Description 查询学生声明周期接口
     * @Date 2021-7-1 17:26
     * @param studentId
     * @return ResultInfo
     */
    @GetMapping("/list/{studentId}")
    public ResultInfo queryLifeCycle(@PathVariable("studentId") Integer studentId){
       log.info("LifeCycleController的queryLifeCycle进入");
       if(studentId == null){
           throw new SystemException(ReturnCode.PARAM_NOT_NULL);
       }

        //根据student_id查询backview回访信息.
        backviewService.selectBackviewByStudentId(studentId);


        //根据student_id查询interview到访信息，将信息封装在InterviewAndBackview的Map中
        interviewService.selectInterviewByStudentId(studentId);


        //根据student_id查询try试听信息,将信息封装在TryAndBackview的Map中
        tryService.selectTryByStudentId(studentId);


        //根据student_id查询报名信息,将信息封装在BaomingAndBakview的Map中
        baomingService.selectBaomingByStudentId(studentId);

        //根据student_id查询Resource,用于声明周期,将信息封装ResourceAndBackview的Map

        log.info("LifeCycleController的queryLifeCycle返回");
        return  resourceService.selectResourceByStudentIdLifeCycle(studentId);

    }
}
